package cn.itcalvin.sncoal.cth.pojo.response.pf;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;

@Data
public class RespPfExport {
    @ExcelProperty("序号")
    @ColumnWidth(10)
    private Integer no;

    @ExcelProperty("系统名称")
    @ColumnWidth(30)
    private String systemName;

    @ExcelProperty("系统总分")
    @ColumnWidth(20)
    private BigDecimal totalScore;

    @ExcelProperty("得分权重")
    @ColumnWidth(20)
    private BigDecimal weight;

    @ExcelProperty("自评人名称")
    @ColumnWidth(20)
    private String pfPerson;

    @ExcelIgnore
    private BigDecimal pfScore;

    @ExcelProperty("自评得分")
    @ColumnWidth(20)
    private BigDecimal pfScoreZz;

    @ExcelIgnore
    private BigDecimal pfScoreWeight;
    @ExcelProperty("自评权重后得分")
    @ColumnWidth(30)
    private BigDecimal pfScoreWeightZz;

    @ExcelProperty("核验人名称")
    @ColumnWidth(20)
    private String hyPerson;


    @ExcelIgnore
    private BigDecimal hyScore;
    @ExcelProperty("核验后得分")
    @ColumnWidth(20)
    private BigDecimal hyScoreZz;



    @ExcelIgnore
    private BigDecimal hyScoreWeight;
    @ExcelProperty("核验后权重得分")
    @ColumnWidth(30)
    private BigDecimal hyScoreWeightZz;

    @ExcelProperty("上一次核验后得分")
    @ColumnWidth(30)
    private BigDecimal hyScoreZzLast;

    public  BigDecimal getPfScoreZz(){
        if(systemName.contains("掘进")){
            if(pfScore==null||pfScore.compareTo(BigDecimal.ZERO)==0){
                return totalScore.multiply(new BigDecimal(0.6)).setScale(2, RoundingMode.HALF_UP);
            }
        }
        return pfScore.setScale(2, RoundingMode.HALF_UP);
    }

    public  BigDecimal getHyScoreZz(){
        if(systemName.contains("掘进")&& StrUtil.isNotBlank(hyPerson) ){
            if(hyScore==null||hyScore.compareTo(BigDecimal.ZERO)==0){
                return totalScore.multiply(new BigDecimal(0.6)).setScale(2, RoundingMode.HALF_UP);
            }
        }
        return hyScore.setScale(2, RoundingMode.HALF_UP);
    }

    public  BigDecimal getPfScoreWeightZz(){
        if(systemName.contains("掘进")){
            if(pfScoreWeight==null||pfScoreWeight.compareTo(BigDecimal.ZERO)==0){
                return totalScore.multiply(weight).multiply(new BigDecimal(0.6)).setScale(2, RoundingMode.HALF_UP);
            }
        }
        return pfScoreWeight.setScale(2, RoundingMode.HALF_UP);
    }

    public  BigDecimal getHyScoreWeightZz(){
        if(systemName.contains("掘进")&& StrUtil.isNotBlank(hyPerson) ){
            if(hyScoreWeight==null||hyScoreWeight.compareTo(BigDecimal.ZERO)==0){
                return totalScore.multiply(weight).multiply(new BigDecimal(0.6)).setScale(2, RoundingMode.HALF_UP);
            }
        }
        return hyScoreWeight.setScale(2, RoundingMode.HALF_UP);
    }
}
